﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TI_4_Limonade_Fabriek.Model;
using TI_4_Limonade_Fabriek.Properties;

namespace TI_4_Limonade_Fabriek
{
    public partial class ConfigScreen : Form
    {
        
        public ConfigScreen()
        {
            InitializeComponent();
        }

        private void ConfigScreen_Load(object sender, EventArgs e) 
        {

            nudMinMengverhouding.Value = Settings.Default.MinMengverhouding;
            nudMaxMengverhouding.Value = Settings.Default.MaxMengverhouding;
            nudMengverhoudingStappen.Value = Settings.Default.MengverhoudingStappen;
            nudAantalBekers.Value = Settings.Default.AantalBekers;

        }

        private void btnUsers_Click(object sender, EventArgs e)
        {
            UserOverviewScreen goScreen = new UserOverviewScreen();
            goScreen.ShowDialog();
        }

        private void ConfigScreen_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Dispose();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void btnBatchOverview_Click(object sender, EventArgs e)
        {
            BatchOverviewScreen boScreen = new BatchOverviewScreen();
            boScreen.ShowDialog();
        }

        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            if (nudMinMengverhouding.Value <= nudMaxMengverhouding.Value)
            {
                Settings.Default.MinMengverhouding = int.Parse(nudMinMengverhouding.Value.ToString());
                Settings.Default.MaxMengverhouding = int.Parse(nudMaxMengverhouding.Value.ToString());
                Settings.Default.AantalBekers = int.Parse(nudAantalBekers.Value.ToString());
                Settings.Default.MengverhoudingStappen = int.Parse(nudMengverhoudingStappen.Value.ToString());
                Settings.Default.Save();
                MessageBox.Show("Instellingen opgeslagen");
            }
            else
            {
                MessageBox.Show("Minimale mengverhouding mag niet hoger zijn dan maximale mengverhouding.");
            }
        }

        private Dictionary<string, int> ConvertToDictionary()
        {
            Dictionary<string, int> dic = new Dictionary<string, int>();

            dic.Add("MinMengverhouding", int.Parse(nudMinMengverhouding.Value.ToString()));
            dic.Add("MaxMengverhouding", int.Parse(nudMaxMengverhouding.Value.ToString()));
            dic.Add("MengverhoudingStappen", int.Parse(nudMengverhoudingStappen.Value.ToString()));
            dic.Add("AantalBekersPerBatch", int.Parse(nudAantalBekers.Value.ToString()));

            return dic;

        }
    }
}
